package com.ruoyi.detection.service.impl;

import com.ruoyi.detection.domain.Users;
import com.ruoyi.detection.mapper.UsersMapper;
import com.ruoyi.detection.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: base-planthopper-detection-master_202130504106_李航
 * @description:
 * @author: LiHang
 * @create: 2021-09-30 08:45
 **/

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UsersMapper usersMapper;

    /**
     * 用户登录，查询登录的信息在数据库中是否存在
     * @param logininfo
     * @return
     */
    @Override
    public List<Users> selectUser(Users logininfo) {
        List<Users> users = usersMapper.selectLogin(logininfo);
        return users;
    }

    /**
     * 用户注册
     * @param registerInfo
     * @return
     */
    @Override
    public boolean register(Users registerInfo) {
        List<Users> users = usersMapper.selectLogin(registerInfo);
        if(users.size()>0){
            return false;
        }
        int i = usersMapper.insertRegister(registerInfo);
        if(i<1){
            return false;
        }else {
            return true;
        }

    }
}
